/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.coraci.anag.gui.docs.mr;

import it.coraci.anag.db.sql.entities.IDDocType;
import it.coraci.anag.db.sql.entities.IDDocument;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JList;
import javax.swing.plaf.basic.BasicComboBoxRenderer;

/**
 *
 * @author Luca
 */
public class DocumentComboBoxRenderer extends BasicComboBoxRenderer{

    public DocumentComboBoxRenderer() {
        this.setOpaque(true);
    }

    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        if(value == null){
            this.setText("nessun documento selezionato");
        }
        if(value instanceof IDDocument){
            this.setText(((IDDocument)value).getType().getType());
        }
        if(isSelected){
            this.setBackground(Color.YELLOW);
        }else{
            this.setBackground(Color.WHITE);
        }
        return this;
    }
    
    
}
